const http = require('http');
const Koa = require('koa');
const socketIo = require('socket.io');
const koaStatic = require('koa-static');

const app = new Koa();
const server = http.Server(app.callback());
const io = socketIo(server)
const PORT = 3232;

app.use(koaStatic(__dirname + '/'));

// 连接成功后，我们监听客户端发来的图片数据，然后转发给所有的客户端
io.on('connect', socket => {
  socket.on('sendImg', (data) => {

    io.emit('receiveImg', data);

  });
});

server.listen(PORT);
